<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 边界符
        /*
            ^ 开头
            $ 结尾
        */
        let reg1 = /^\d/; //这样就代表未来的字符串必须以数字开头
        console.log(reg1.test('1zz')); //true
        console.log(reg1.test('z1z')); //false

        console.log('----------------------------------------');

        let reg2 = /\d$/; //这样就代表未来的字符串必须以数字结尾
        console.log(reg2.test('1zz')); //false
        console.log(reg2.test('z1z1')); //true

        console.log('----------------------------------------');

        // ^和$当然是可以配合使用的
        let reg3 = /^abc$/;//开头结尾都必须是abc,
        console.log(reg3.test('abc'));//true
        console.log(reg3.test('abcabc'));//false
    </script>
</body>

</html>